package cn.com.nes.site.service.crm.order;

import cn.com.nes.mybatis.agent.ope.entity.SaleOrderInfo;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.bo.crm.sale.*;
import cn.com.nes.site.entity.vo.crm.sale.*;
import cn.com.nes.site.service.crm.order.bo.CancelSaleOrderBO;
import cn.com.nes.site.service.crm.order.bo.QueryHaveWorkOrderBO;
import cn.com.nes.site.service.crm.order.bo.QuerySaleOrderDetailBO;
import cn.com.nes.site.service.crm.order.bo.SaleOrderBO;
import cn.com.nes.site.service.crm.order.dto.SaleOrderDetailDTO;
import cn.com.nes.site.service.crm.order.dto.SaleOrderInfoDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.Date;
import java.util.List;

/**
 * 销售订单服务
 */
public interface SaleOrderInfoService extends IService<SaleOrderInfo> {

    PageData saveOrder(SaleOrderInfoVO vo) throws Exception;


    SaleOrderInfoDTO saleOrderSave(SaleOrderBO saleOrderBO) throws Exception;


    Page<SaleOrderInfoDTO> getOrderPage(SaleOrderPageVO vo) throws Exception;


    PageData getOrderDetail(GetSaleOrderDeatilsVO vo) throws Exception;


    SaleOrderInfoDTO getOrderDetatil(Long saleOrderId) throws Exception;


    PageData delOrderByOrderId(DeleteSaleOrderVO vo) throws Exception;


    PageData enableSaleOrder(EnableSaleOrderBO bo) throws Exception;


    /**
     * 根据订单ID，查询订单信息
     * @param orderId
     * @return
     */
    SaleOrderInfo getSaleOrderById(Long orderId) throws Exception;


    /**
     * 根据客户ID，查询订单信息
     * @param customerId
     * @return
     */
    List<SaleOrderInfo> getSaleOrderByCustomer(Long customerId) throws Exception;


    List<SaleOrderInfo> getSale(String customerId, String opportunityId);


    /**
     * 根据商机UUID获取销售订单信息。
     *
     * @param opportunityUuid 商机的唯一标识符
     * @return 包含销售订单信息的对象
     * @throws Exception 如果获取销售订单信息时发生异常
     */
    SaleOrderInfo getSaleOrderNew(String opportunityUuid) throws Exception;


    /**
     * 根据商机ID，查询订单列表
     * @param opportunityUuid 商机的唯一标识符
     * @return
     */
    List<SaleOrderInfo> getOrders(String opportunityUuid) throws Exception;


    /**
     * 根据商机UUID列表获取销售订单信息。
     * @param opportunityUuids 商机UUID列表
     * @return 包含销售订单信息的列表
     * @throws Exception 如果获取销售订单信息时发生异常
     */
    List<SaleOrderInfo> getSaleOrders(List<String> opportunityUuids) throws Exception;


    /**
     * 切换销售单状态
     * @param bo
     * @return
     */
    PageData changeSaleOrderStatus(ChangeSaleOrderStatusBO bo) throws Exception;


    /**
     * 复制销售单
     * @param copySaleOrderInfoBo
     * @return
     */
    PageData copySaleOrder(CopySaleOrderInfoBO copySaleOrderInfoBo) throws Exception;


    /**
     * 标记订单派单状态
     * @param vo
     * @return
     */
    PageData markSaleOrderDispatched(MarkSaleOrderDispatchedVO vo) throws Exception;


    /**
     * 重载接口 - 查询订单分页 - 安装工单入口
     * @param vo
     * @return
     */
    PageData getUnDispatchedSaleOrderPage(UnDispatchedSaleOrderPageBO vo) throws Exception;


    SaleOrderInfo getSaleOrder(String opportunityUuid);


    SaleOrderInfoDTO getPriceMastersAndDetails(Long saleOrderId) throws Exception;


    SaleOrderInfoDTO getPriceMastersAndDetails(String opportunityId) throws Exception;


    Page<SaleOrderInfoDTO> getPriceMastersAndDetails(SaleOrderPageBO bo) throws Exception;


    /**
     * 根据客户id查询销售订单信息
     */
    List<SaleOrderInfoDTO> getSaleOrderInfoListByCustomerId(List<String> customerIdList);


    /**
     * 删除销售单
     * @param deletedCustomerIds 要删除的客户ID列表
     * @param operateUserId      操作人ID
     * @param operateDate        操作时间
     */
    void deleteByCustomerIds(List<String> deletedCustomerIds, Long operateUserId, Date operateDate) throws Exception;


    Integer getSystemNumberByOpportunityList(List<String> opportunities);


    /**
     * 销售订单支付成功
     * @param saleOrderBO
     * @return
     */
    SaleOrderInfo orderPaymentSuccess(SaleOrderBO saleOrderBO) throws Exception;


    /**
     * 批量撤销安装工单，修改系统单的派单状态
     */
    void cancelSaleOrder(CancelSaleOrderBO cancelSaleOrderBO);

    /**
     * 查询销售订单详情
     */
    SaleOrderDetailDTO getSaleOrderDetail(QuerySaleOrderDetailBO queryBO);

    /**
     * 批量确认销售订单
     */
    String batchSaleOrderPaymentSuccess(BatchSaleOrderPaymentSuccessBO bo);

    /**
     * 查询是否有安装工单
     */
    Boolean queryHaveWorkOrder(QueryHaveWorkOrderBO queryBO);

}
